﻿// GLOBAL VARIABLES
var content = view.appendElement( "<div height=\""+view.height+"\" width=\""+view.width+"\"></div>" );
var manager;
var todo;
var doing;
var done;
var preferences;
var colors;
var impeded;
var todoPosts = [];
var doingPosts = [];
var donePosts = [];
var impPosts = [];
var slide;
var user;

var userDefault = new User(0);
userDefault.setDefaultData();

// Initial event
function view_onOpen() {
    // Check resizing.js for the functions used above
    
    //var userTest = userDefault.toJSONString();
    //userTest = parseJSONUser( userTest );
    //debug.info( userTest.getProject().todo.getName() );
    //test_server();
    
    view.onsizing = view_onSizing;
    view.onsize = resizeGui;
    view.ondock = view_onDock;
    view.onundock = view_onUndock;
    view.onminimize = view_onMinimize;
    view.onrestore = view_onRestore;
    view.onmousewheel = view_onMouseWheel;
    view.onmousemove = view_onMouseMove;

    // Setting default values
    options.putDefaultValue("width", parameters.defaultWidth);
    options.putDefaultValue("height", parameters.defaultHeight);
    options.putDefaultValue("username",parameters.defaultUsername);
    options.putDefaultValue("password",parameters.defaultPassword);
    options.putDefaultValue("page", parameters.defaultPage);
    options.putDefaultValue("layoutExpired", parameters.layoutExpired);
    options.putDefaultValue("layoutToday", parameters.layoutToday);
    options.putDefaultValue("layoutNear", parameters.layoutNearToExpire);
    options.putDefaultValue("layoutTask", parameters.layoutTask);
    options.putDefaultValue("user", userDefault.toJSONString() );

    // Applying the defaut size to the first view
    view.resizeTo( options.getValue("width"), options.getValue("height") );
    user = parseJSONUser( options("user") );

    // Drawing methods
    drawGui(options.getValue("page"));
}                                       

